package cn.tedu.mintmall.controller;

import cn.tedu.mintmall.dto.ProductDTO;
import cn.tedu.mintmall.restful.JsonResult;
import cn.tedu.mintmall.service.IProductService;
import cn.tedu.mintmall.vo.ProductVO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/product")
@Api(tags = "前台商品显示")
public class ProductController {

    @Autowired
    private IProductService productService;

    @GetMapping("/select/obscureTitle")
    @ApiOperation("模糊标题查询商品信息")
    public JsonResult<List<ProductVO>> selectByObscureTitle(ProductDTO productDTO){
        List<ProductVO> productVOS = productService.selectByObscureTitle(productDTO);
        return JsonResult.ok("返回成功",productVOS);
    }

    @GetMapping("/select/byCategoryId")
    @ApiOperation("根据类别id查询商品")
    public JsonResult<List<ProductVO>> selectByCategoryId(ProductDTO productDTO){
        List<ProductVO> productVOS = productService.selectByCategoryId(productDTO);
        return JsonResult.ok("返回成功",productVOS);
    }

    @GetMapping("/select/byImgId")
    @ApiOperation("根据图片id查询商品")
    public JsonResult<List<ProductVO>> selectByImgId(ProductDTO productDTO){
        List<ProductVO> productVOS = productService.selectByImgId(productDTO);
        return JsonResult.ok("返回成功",productVOS);
    }

}
